package core;

import config.AppConfig;
import service.UserService;

public class TestIoc {
    public static void main(String[] args) {
        System.out.println("🚀 启动自定义IOC容器...\n");

        // 初始化容器
        MyApplicationContext context = new MyApplicationContext(AppConfig.class);

        System.out.println();

        // 获取Bean（方式一：按名称）
        UserService userService1 = context.getBean("userService");
        userService1.sayHello();

        // 获取Bean（方式二：按类型）
        UserService userService2 = context.getBean(UserService.class);
        userService2.sayHello();

        System.out.println("\n✅ 容器中所有Bean加载完毕！");
    }
}